<template>
	<view class="wrap">
		<view class="top">
			<view class="loginState" v-if="loginInfo.length">
				<view class="userPic">
					<image src="../../static/tabbar/logo.png" mode="widthFix"></image>
				</view>
				<view class="username">{{loginInfo}}</view>
				<view class="exit" @click="exitLogin">退出登录</view>
			</view>
			<view class="loginNull" v-else>
				<navigator class="loginBtn" url="/pages/login/login">登录</navigator>
			</view>
		</view>
		<view class="main">
			<navigator class="select" v-for="(item,index) in setList" :key="index" :url="item.url">
				<view class="left">{{item.name}}</view>
				<view class="right">&gt;</view>
			</navigator>
			
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				loginInfo:"",
				setList:[
					{"name":"全部订单",url:"/pages/personPage/personPage"},
					{"name":"会员中心",url:"/pages/winPage/winPage"},
					{"name":"我的优惠",url:"/pages/publicPage/publicPage"},
					{"name":"服务中心",url:"/pages/publicPage/publicPage"},
					{"name":"小米之家",url:"/pages/publicPage/publicPage"},
					{"name":"设置",url:"/pages/publicPage/publicPage"},
				]
			}
		},
		onShow() {
			if(uni.getStorageSync("loginInfo")){
				this.loginInfo = uni.getStorageSync("loginInfo")
			}else{
				this.loginInfo = []
			}
		},
		methods: {
			exitLogin(){
				uni.showToast({
					title:"退出成功"
				})
				uni.removeStorageSync("loginInfo")
				this.loginInfo = ""
			}
		}
	}
</script>

<style lang="less">
	.wrap{
		.top{
			padding: 30rpx;
			display: flex;
			flex-direction: column;
			width: 100%;
			height: 500rpx;
			background-color: orangered;
			align-items: center;
			justify-content: center;
			color: white;
			.loginState{
				display: flex;
				justify-content: center;
				flex-direction: column;
				align-items: center;
				.userPic{
					width: 150rpx;
					height: 150rpx;
					border-radius: 50%;
					overflow: hidden;
					image{
						width: 100%;
					}
				}
				.exit{
					width: 180rpx;
					height: 60rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					border: 1rpx solid white;
					border-radius: 10rpx;
					margin: 10rpx 0;
				}
			}
			.loginNull{
				.loginBtn{
					width: 180rpx;
					height: 60rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					border: 1rpx solid white;
					border-radius: 10rpx;
					margin: 10rpx 0;
				}
			}
		}
		.main{
			padding: 0 30rpx;
			.select{
				height: 100rpx;
				padding: 0 30rpx;
				display: flex;
				justify-content:space-between;
				align-items: center;
				border-bottom: 1rpx solid #EFEFEF;
				.right{
					font-size: 36rpx;
					font-weight: bold;
					color: gray;
				}
			}
		}
	}
</style>
